home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-29 | 2.1 KB | 76 lines | [TEXT/CWIE] |
- // VideoAccessor.cp, the VideoAccessor class, to be used for direct access to
- // video pixel-maps.
-
- // copyright © 1995, Macneil Shonle. All rights reserved.
-
- #ifndef __VIDEOACCESSOR__
- #include <VideoAccessor.h>
- #endif
-
- #ifndef __QDOFFSCREEN__
- #include <QDOffscreen.h>
- #endif
-
- static PixMapHandle GetGlobalPointPixMap(Point);
-
- // sets up direct blitting information for video memory
- // may throw: xalloc
- VideoAccessor::VideoAccessor(const Rect& r) throw(xalloc)
- {
- construct(r);
- }
-
- // intentionally left blank
- VideoAccessor::~VideoAccessor()
- {
- }
-
- // makes a copy of the given VideoAccessor
- // may throw: xalloc
- VideoAccessor& VideoAccessor::operator=(const VideoAccessor& va) throw(xalloc)
- {
- this->BufferAccessor::operator=(va);
- return *this;
- }
-
- // caches in the given global rectange's screen pixel-map's pixel information
- // may throw: xalloc
- VideoAccessor& VideoAccessor::operator=(const Rect& r) throw(xalloc)
- {
- construct(r);
- return *this;
- }
-
- // private member-function to implement the construction of the BufferAccessor for
- // a area of video-memory
- // may throw: xalloc
- void VideoAccessor::construct(const Rect& r) throw(xalloc)
- {
- theHeight = r.bottom - r.top;
- theWidth = r.right - r.left;
-
- PixMapHandle pixMap = ::GetGlobalPointPixMap(*(Point*)&r);
- theRowBytes = (*pixMap)->rowBytes & 0x3FFFL; // see QD 15 - RowBytes Revealed II
-
- // get the base address (with any arbitrary bit depth)
- PixelPtr baseAddr = PixelPtr(::GetPixBaseAddr(pixMap)) + r.top * theRowBytes;
- if ((*pixMap)->pixelSize < 8)
- baseAddr += r.left / (8 / (*pixMap)->pixelSize);
- else
- baseAddr += r.left * ((*pixMap)->pixelSize / 8);
-
- setArray(baseAddr, theRowBytes, theHeight);
- mmuMode = true; // see Graphic Truffles August 1992
- }
-
- // returns the PixMap that contains the global-point passed, returns the
- // main device if not found. See Graphic Truffles, May 1992
- PixMapHandle GetGlobalPointPixMap(Point pt)
- {
- // walk through all monitors hooked to the machine
- for (GDHandle device=::GetDeviceList(); device; device=::GetNextDevice(device))
- if (PtInRect(pt, &(*device)->gdRect))
- return (*device)->gdPMap;
-
- return (*::GetMainDevice())->gdPMap;
- }